<?php

namespace App\Services\MakeProductOrder;

use App\Models\PayConfig;
use App\Models\Address;
use App\Models\ProductSku;
use App\Http\Controllers\Api\V1\Requests\FormRequest;

class MakeProductOrderRequest extends FormRequest
{
	protected ?Address $address = null;

	public function rules(): array
	{
		

		return [
			'pay_config_id' => ['required', $this->config()]
		];
	}

	public function config()
	{
		return function ($attribute, $value, $fail) {
			$config = PayConfig::find($value);
			if (!$config) {
				return $fail('此支付方式不存在');
			}
			return true;
		};
	}

}
